package com.heima.wemedia.controller.v1;

import com.heima.apis.wemedia.WmUserControllerApi;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmUserDto;
import com.heima.model.wemedia.pojos.WmUser;
import com.heima.wemedia.service.WmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping
public class WmUserController implements WmUserControllerApi {

    @Autowired
    private WmUserService wmUserService;

    /**
     * 自媒体添加用户
     *
     * @param wmUser
     * @return
     */
    @PostMapping("/api/v1/user/seveWmUser")
    @Override
    public ResponseResult seveWmUser(@RequestBody WmUser wmUser) {
        return wmUserService.seveWmUser(wmUser);
    }

    /**
     * 用户登录
     *
     * @param dto
     * @return
     */
    @PostMapping("/login/in")
    @Override
    public ResponseResult login(@RequestBody WmUserDto dto) {
        return wmUserService.login(dto);
    }

    /**
     * 根据id获取自媒体人信息
     *
     * @param id
     * @return
     */
    @GetMapping("/api/v1/user/findOne/{id}")
    @Override
    public WmUser findWmUserById(@PathVariable Long id) {
        return wmUserService.getById(id);
    }

}
